package com.example.mqtt.mica.mqtt.config;

import net.dreamlu.iot.mqtt.core.client.MqttClientCreator;
import net.dreamlu.iot.mqtt.spring.client.MqttClientCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ghl
 * @date 2023/11/16 12:01
 * @note
 */
@Configuration(proxyBeanMethods = false)
public class MqttClientCustomizerConfiguration {

    @Bean
    public MqttClientCustomizer mqttClientCustomizer() {
        return new MqttClientCustomizer() {
            @Override
            public void customize(MqttClientCreator creator) {
                // 此处可自定义配置 creator，会覆盖 yml 中的配置
                System.out.println("----------------MqttServerCustomizer-----------------");
                creator.clientId("mica-client-" + System.currentTimeMillis());
            }
        };
    }

}
